package mx.com.matersys.vacs.utils;

import java.io.*;
import java.net.*;

public class MessageSMS {

	/**
	 * @param args
	 * @throws MalformedURLException 
	 */
	public static void main(String[] args) {
		
		String requestUrl ;
		String recipient = "+525518857862,+525532606279,+525539964490";   //
		String message = "SMS Test! que px :P";
		String username = "MatersySM09";
		String password = "9800xiC";
		String originator = "06201234567";
		//http://api.quiubas.com:9501/api?action=sendmessage&username=MatersySM09&password=9800xiC&recipient=+525518857862&messagedata=MENSAJE&responseformat=html
		//http://api.quiubas.com:9501/api?action=sendmessage&username=MatersySM09&password=9800xiC&recipient=+525518857862,+525532606279&messagedata=Hola%20Mundo&responseformat=html
/*		http://api.quiubas.com:9501/api?action=sendmessage&
		username=MatersySM09&
	    password=9800xiC&
	    recipient=+525518857862&
	    messagedata=MENSAJE&
	    responseformat=html
		*/	
			
	
		try {
	/*		requestUrl  = "http://www.quiubas.com:9501/api?action=sendmessage&" +
            "username=" + URLEncoder.encode(username, "UTF-8") +
            "&password=" + URLEncoder.encode(password, "UTF-8") + 
            "&recipient=" + URLEncoder.encode(recipient, "UTF-8") + 
            "&messagedata=" + URLEncoder.encode(message, "UTF-8") +
            "&responseformat=html";
		*/	
			requestUrl  = "http://api.quiubas.com:9501/api?action=sendmessage&" +
		            "username=" + URLEncoder.encode(username, "UTF-8") +
		            "&password=" + URLEncoder.encode(password, "UTF-8")  + 
		            "&recipient=" +URLEncoder.encode(recipient, "UTF-8")  + 
		            "&messagedata=" +URLEncoder.encode(message, "UTF-8") +
		            "&responseformat=html";
		  System.out.println(requestUrl);
			
		 for(int i=0;i<3;++i){ 
		  URL url = new URL(requestUrl);		  
		  HttpURLConnection uc = (HttpURLConnection)url.openConnection();
		  
		  System.out.println(uc.getResponseMessage()+ "|"+uc.getContentType());

		  uc.disconnect();
		}		  
		  
		} catch(Exception ex) {
			System.out.println(ex.getMessage());
			
		}
		 

	}
	
	

}
